Skip to content

Add strict latest freshness validation#37

Closed
Pigbibi wants to merge 2 commits into
mainfrom
codex/slice-b-strict-latest
Closed

Add strict latest freshness validation#37
Pigbibi wants to merge 2 commits into
mainfrom
codex/slice-b-strict-latest

Conversation

@Pigbibi

@Pigbibi Pigbibi commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add explicit strict/latest validation for v2 signals and linked theme artifacts
  • validate linked theme schema, gate, and deterministic reference-date freshness
  • keep validate_signal() historical compatibility semantics unchanged
  • make scheduled/live dispatch validation explicitly strict; --allow-expired only bypasses expiry

Validation

  • python3 -m pytest -q (45 passed)
  • python3 scripts/validate_latest_signal.py examples/latest_signal.example.json
  • git diff --check

Research-only scope; no execution, portfolio, account, or production dependency changes.

Co-Authored-By: Codex <noreply@openai.com>
@github-actions

github-actions Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

🤖 Codex PR Review

🚫 Merge blocked: 2 serious issue(s) found in high-risk files

🚫 Blocking Issues

These issues must be fixed before this PR can be merged:

1. 🟠 [HIGH] Logic in src/research_signal_context_pipelines/schema.py

validate_latest_signal() never checks that the linked theme snapshot was built for the same deterministic reference date as the signal itself; it only checks whether the theme artifact is unexpired as of effective_date. A stale theme snapshot with as_of from an earlier date will still pass as long as its expires_at is in the future, so a newer signal can be validated against old context and dispatched with the wrong theme inputs. (line 157)

Suggestion: After loading the theme artifact, compare its as_of (or the pipeline’s canonical reference-date field) against the signal’s own reference date and reject mismatches. Do not rely on expires_at alone for freshness.

2. 🟠 [HIGH] Logic in src/research_signal_context_pipelines/schema.py

The new theme_artifact_path override bypasses the signal’s recorded linkage entirely. When this argument is supplied, strict validation reads that file without verifying it is one of payload['evidence']['sources'], so a caller can validate a signal against any passing theme snapshot even if the signal actually references an expired or blocked artifact. That defeats the PR’s stated guarantee that the linked theme artifact is being validated. (line 149)

Suggestion: Require the override path to resolve to one of the signal’s declared evidence source paths, or remove the override from strict production validation paths and only allow the artifact referenced by the payload itself.


Review by Codex PR Review bot • PR

Co-Authored-By: Codex <noreply@openai.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8af26fa3ff

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".


- name: Validate existing latest signal if present
run: python scripts/validate_latest_signal.py --allow-missing
run: python scripts/validate_latest_signal.py --allow-missing --strict-latest

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep shadow dispatch from failing on stale artifacts

With the artifacts committed in this checkout, this command exits nonzero before the job can build a replacement context: data/output/latest_signal.json expired on 2026-06-30 and points at data/output/theme_momentum_snapshot.json, which is still schema 1 and has no required gate. Because this step runs first for both schedule and workflow_dispatch, the shadow dispatch workflow is blocked until a separate artifact refresh is merged; either update the committed artifacts in this change or avoid strict freshness/gate checks on the pre-existing output.

Useful? React with 👍 / 👎.

allow_expired: bool = False,
) -> None:
"""Validate a current signal and its linked theme artifact fail-closed."""
validate_signal(payload)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Require v2 metadata for strict latest signals

In strict-latest mode, a fresh schema 1 signal with no model_version or scoring_version still passes because this call intentionally preserves the historical v1 compatibility path and there is no later check that the top-level signal is schema 2. That leaves the new strict validator unable to enforce provenance/version metadata on the current latest_signal.json, even though the linked theme artifact is forced through strict v2 validation.

Useful? React with 👍 / 👎.

Comment on lines +253 to +257
"gate": {
"status": "pass",
"allow_downstream_recommendation": True,
"reasons": [],
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Block the gate when theme coverage is unusable

When the snapshot is built from partial price data, the artifact can record missing symbols, insufficient history, or unranked themes but still emits a passing gate with allow_downstream_recommendation: True. Since strict latest validation now trusts this gate as the fail-closed signal, a partial snapshot can be accepted for downstream recommendation context even when parts of the configured taxonomy had no usable ranking data.

Useful? React with 👍 / 👎.

Comment on lines +160 to +164
validate_theme_momentum_snapshot(
theme_payload,
reference_date=effective_date,
compatibility=False,
check_freshness=True,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject theme snapshots dated after the signal

This strict check only tests the linked theme artifact against the wall/reference date, so a signal with as_of January 1 can still validate while referencing a theme snapshot whose own as_of is January 20, as long as that future snapshot has not expired. That breaks the point-in-time contract for saved signals and can leak future momentum data into replay or downstream research context.

Useful? React with 👍 / 👎.

@Pigbibi

Pigbibi commented Jul 13, 2026

Copy link
Copy Markdown
Contributor Author

Superseded-by-smaller-slice: Slice B has been re-cut into B1 linkage integrity and a later B2 freshness slice. This PR is closed without cherry-picking or reusing its commits; its review/test history is retained as evidence.

@Pigbibi Pigbibi closed this Jul 13, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant